import request from '@/utils/request'

export default {
  roleList(page, limit, searchObj) {
    return request({
      url: `/system/role/list/${page}/${limit}`,
      method: 'post',
      data: searchObj
    });
  },
  addRole(role) {
    return request({
      url: '/system/role/add',
      method: 'post',
      data: role
    });
  },
  updateRole(role) {
    return request({
      url: '/system/role/update',
      method: 'put',
      data: role
    });
  },
  removeById(id) {
    return request({
      url: '/system/role/remove/' + id,
      method: 'delete'
    });
  },
  removeBatchs(idList) {
    return request({
      url: '/system/role/removeBatchs',
      method: 'delete',
      data: idList
    });
  },
  getRoleById(id) {
    return request({
      url: '/system/role/get/' + id,
      method: 'get'
    });
  },
  changeRoleState(id, state) {
    const data = {
      id,
      state
    }
    return request({
      url: '/system/role/changeRoleState',
      method: 'put',
      data: data
    });
  },
  saveRoleMenu(role) {
    return request({
      url: '/system/role/save',
      method: 'post',
      data: role
    });
  },
  allRoleList() {
    return request({
      url: '/system/role/all',
      method: 'get'
    });
  },
}